<?php
/**
 * 消费订单同步日志
 * Date: 2024/11/26
 * Time: 10:31
 */

namespace App\Models\CustomerDelivery;


use Illuminate\Database\Eloquent\Model;

class CustomerLogs extends Model
{

    protected $table = 'customer_logs';

    protected $guarded  = [];

    public static $orderSync = 'order_sync';
    public static $customerOrderSync = 'customer_order_sync';
    public static $customerOrderException = 'customer_order_exception';
    public static $customerOrderLogistics = 'customer_order_logistics';

    public static $cnOrder = 'cn_order'; //国内订单(国内)
    public static $fbaOutboundOrder = 'fba_outbound_order'; //FBA多渠道订单(amazon平台)
    public static $overseasInboundOrder = 'overseas_inbound_order'; //海外仓入库订单(Rakuten谷仓)

    /**
     * 添加日志
     * @param $type
     * @param $content
     * @param array $logData
     * @param null $orderIds
     * @return \Illuminate\Database\Eloquent\Builder|Model
     */
    public static function logs($type, $content, $logData = [], $orderIds = []){
        return self::query()->create([
            'type' => $type,
            'content' => $content,
            'data' => json_encode($logData,JSON_UNESCAPED_UNICODE),
            'order_ids' => json_encode($orderIds,JSON_UNESCAPED_UNICODE)
        ]);
    }

}
